/**
 * Created by minigci.he on 16/9/13.
 */
console.log('-------------------------')
console.log('test6')


let validator = {
    set: function(obj, prop, value, receiver){

        if(prop == 'age'){
            if(!Number.isInteger(value)){
                throw new TypeError('The age is not an integer')
            }
            if(value > 200){
                throw new RangeError('The age seems invalid')
            }
        }

        return obj[prop] = value;
    }

}

let person = new Proxy({age: 0}, validator);

person.age = 100;
console.log(person);
// person.age = 'young'
// person.age = 300;